#This file is used in client side, specifically, mp002, not in pcron server, work with win cron task(incomingFilesHandler.xml)

#print incoming order and move

Set-Location C:\Users\cs001\Desktop\FC3.0\oms2
Move-Item -Force -Path orders\incoming\*.pdf -Destination orders\staging

#print orders files
Get-ChildItem -Path orders\staging -Filter *-order-*.pdf -Recurse | ForEach-Object {
    #Start-Process -FilePath $_.FullName -Verb Print -Wait #if using -Wait option, acrobat reader will stay there forever, else the file will be deleted before printed
    echo "printing $_.fullname..."
    Start-Process -FilePath $_.fullname -Verb Print -PassThru | %{sleep 9;$_} | kill 
}

Move-Item -Force -Path orders\staging\*.pdf -Destination orders\processed
